using System;
using System.Collections.Generic;

#if WINDOWS_PHONE71
using Microsoft.Phone.Scheduler;

namespace WindowsPhoneEssentials.Abstractions
{
    public class ScheduledActionServiceWrapper : IScheduledActionService
    {
        /// <summary>
        /// Adds a new reminder.
        /// </summary>
        /// <param name="name">The name of the reminder.</param>
        /// <param name="title">The title of the notification.</param>
        /// <param name="body">The body of the notification.</param>
        /// <param name="beginTime">The time of the reminder.</param>
        /// <param name="navigationUri">The URI to be passed to the application on launch.</param>
        /// <param name="recurrence">The recurrence of the reminder.</param>
        /// <returns>The new <see cref="Reminder"/> instance.</returns>
        public Reminder AddReminder(string name, string title, string body, DateTime beginTime, Uri navigationUri, RecurrenceInterval recurrence = RecurrenceInterval.None)
        {
            if (Find(name) != null)
                Remove(name);

            var reminder = new Reminder(name)
                               {
                                   BeginTime = beginTime,
                                   Content = body,
                                   NavigationUri = navigationUri,
                                   RecurrenceType = recurrence,
                                   Title = title
                               };

            Add(reminder);

            return reminder;
        }

        public void Add(ScheduledAction action)
        {
            ScheduledActionService.Add(action);
        }

        public ScheduledAction Find(string name)
        {
            return ScheduledActionService.Find(name);
        }

        public IEnumerable<T> GetActions<T>() where T : ScheduledAction
        {
            return ScheduledActionService.GetActions<T>();
        }

        public void Remove(string name)
        {
            ScheduledActionService.Remove(name);
        }

        public void Replace(ScheduledAction action)
        {
            ScheduledActionService.Replace(action);
        }

        public void LaunchForTest(string name, TimeSpan delay)
        {
            ScheduledActionService.LaunchForTest(name, delay);
        }
    }
}
#endif